/*   Copyright 2012 Julian Aloofi

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#ifndef TACTICUS_COMMON_HPP
#define TACTICUS_COMMON_HPP

#include <SFML/System/Vector2.hpp>
#include "Game/Field.hpp"

namespace Tacticus
{

namespace Common
{

class Coordinate
{
public:
    Coordinate(float x = -1.f, float y = -1.f);
    Coordinate(sf::Vector2f vector);
    float x;
    float y;

    operator bool() const { return (x == -1.f && y == -1.f) ? false : true; }
    operator sf::Vector2f() const { return sf::Vector2f(x, y); }
    bool operator==(const Coordinate &rhs) const;
    bool operator!=(const Coordinate &rhs) const;
    Coordinate operator+(const Coordinate &rhs) const;
    Coordinate operator-(const Coordinate &rhs) const;
};

typedef std::pair<Coordinate, Field> CoordinateField;

typedef Coordinate ScreenCoordinate;

bool isOnTheBoard(const Coordinate &x);

bool areOnTheBoard(const Coordinate &x, const Coordinate &y);

bool isOnTheScreen(const Coordinate &x);

size_t findStr(std::string &string, std::string searchFor);

}
}

#endif
